import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import type { App } from 'vue'
// @ts-ignore
import { Layout, getParentLayout } from '@/utils/routerHelper'
import { useI18n } from '@/hooks/web/useI18n'

const { t } = useI18n()

export const constantRouterMap: AppRouteRecordRaw[] = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    name: 'Root',
    meta: {
      hidden: true
    }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    name: 'Home',
    meta: {
      hidden: false
    },
    children: [
      {
        path: 'home',
        component: () => import('@/views/Home/index.vue'),
        name: 'HomePage',
        meta: {
          title: '首页',
          canTo: true,
          affix: true
        }
      }
    ]
  },
  {
    path: '/redirect',
    component: Layout,
    name: 'RedirectParent',
    children: [
      {
        path: '/redirect/:path(.*)',
        name: 'Redirect',
        component: () => import('@/views/Redirect/Redirect.vue'),
        meta: {}
      }
    ],
    meta: {
      hidden: true,
      noTagsView: true
    }
  },
  {
    path: '/login',
    component: () => import('@/views/Login/Login.vue'),
    name: 'Login',
    meta: {
      hidden: true,
      title: t('router.login'),
      noTagsView: true
    }
  },
  {
    path: '/:catchAll(.*)',
    component: () => import('@/views/Error/404.vue'),
    meta: {
      hidden: true,
      title: '404',
      noTagsView: true
    }
  },
  {
    path: '/404',
    component: () => import('@/views/Error/404.vue'),
    name: 'NoFind',
    meta: {
      hidden: true,
      title: '404',
      noTagsView: true
    }
  }
]

export const asyncRouterMap: AppRouteRecordRaw[] = [
  {
    path: '/admin',
    component: Layout,
    redirect: '/admin/admin/page',
    name: 'Admin',
    meta: {
      title: t('router.admin.admin.menu'),
      alwaysShow: true,
      icon: 'carbon:skill-level-advanced'
    },
    children: [
      {
        path: 'admin-list',
        component: () => import('@/views/Admin/AdminList.vue'),
        name: 'AdminList',
        meta: {
          title: t('router.adminList')
        }
      },
      {
        path: 'role-management',
        component: () => import('@/views/Admin/RoleManagement.vue'),
        name: 'RoleManagement',
        meta: {
          title: t('router.roleManagement')
        }
      },
      {
        path: 'permission-management',
        component: () => import('@/views/Admin/PermissionManagement.vue'),
        name: 'PermissionManagement',
        meta: {
          title: t('router.permissionManagement')
        }
      },
      {
        path: 'log-management',
        component: () => import('@/views/Admin/LogManagement.vue'),
        name: 'LogManagement',
        meta: {
          title: t('router.logManagement')
        }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    redirect: '/supplier/supplier-management',
    name: 'Supplier',
    meta: {
      title: t('router.supplier.supplier.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'supplier-management',
        component: () => import('@/views/Supplier/Supplier/Page.vue'),
        name: 'SupplierManagement',
        meta: {
          title: t('router.supplier.supplier.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Supplier/Supplier/Detail.vue'),
            name: 'SupplierDetail',
            meta: {
              title: t('router.supplier.supplier.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Supplier/Supplier/Add.vue'),
            name: 'SupplierAdd',
            meta: {
              title: t('router.supplier.supplier.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Supplier/Supplier/Edit.vue'),
            name: 'SupplierEdit',
            meta: {
              title: t('router.supplier.supplier.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'supplier-contact-management',
        component: () => import('@/views/Supplier/SupplierContact/Page.vue'),
        name: 'SupplierContactManagement',
        meta: {
          title: t('router.supplier.supplierContact.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Supplier/SupplierContact/Detail.vue'),
            name: 'SupplierContactDetail',
            meta: {
              title: t('router.supplier.supplierContact.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Supplier/SupplierContact/Add.vue'),
            name: 'SupplierContactAdd',
            meta: {
              title: t('router.supplier.supplierContact.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Supplier/SupplierContact/Edit.vue'),
            name: 'SupplierContactEdit',
            meta: {
              title: t('router.supplier.supplierContact.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      }
    ]
  },
  {
    path: '/purchase',
    component: Layout,
    redirect: '/purchase/purchase-order-management',
    name: 'Purchase',
    meta: {
      title: t('router.purchase.purchase.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'purchase-order-management',
        component: () => import('@/views/Purchase/Purchase/Page.vue'),
        name: 'PurchaseOrderManagement',
        meta: {
          title: t('router.purchase.purchase.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Purchase/Purchase/Detail.vue'),
            name: 'PurchaseDetail',
            meta: {
              title: t('router.purchase.purchase.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'logisticsPage',
            component: () => import('@/views/Purchase/Purchase/logistics.vue'),
            name: 'LogisticsPage',
            meta: {
              title: t('router.purchase.purchase.logistics'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Purchase/Purchase/Add.vue'),
            name: 'PurchaseAdd',
            meta: {
              title: t('router.purchase.purchase.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Purchase/Purchase/Edit.vue'),
            name: 'PurchaseEdit',
            meta: {
              title: t('router.purchase.purchase.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'examine/:id?',
            component: () => import('@/views/Purchase/Purchase/Examine.vue'),
            name: 'PurchaseExamine',
            meta: {
              title: t('router.purchase.audit.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'payment/:id?',
            component: () => import('@/views/Purchase/Purchase/PaymentAdd.vue'),
            name: 'PurchasePayment',
            meta: {
              title: t('router.purchase.payment.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'entry',
            component: () => import('@/views/Purchase/Purchase/TempEntry.vue'),
            name: 'Entry',
            meta: {
              title: t('router.purchase.purchase.entry'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'futures_entry/:id?',
            component: () => import('@/views/Purchase/Purchase/FuturesEntry.vue'),
            name: 'FuturesEntry',
            meta: {
              title: t('router.purchase.futures_entry'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'payment-order-management',
        component: () => import('@/views/Purchase/Payment/Page.vue'),
        name: 'PaymentManagement',
        meta: {
          title: t('router.purchase.payment.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Purchase/Payment/Detail.vue'),
            name: 'PaymentDetail',
            meta: {
              title: t('router.purchase.payment.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Purchase/Payment/Edit.vue'),
            name: 'PaymentEdit',
            meta: {
              title: t('router.purchase.payment.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'examine/:id?',
            component: () => import('@/views/Purchase/Payment/Examine.vue'),
            name: 'PaymentExamine',
            meta: {
              title: t('router.purchase.payment.examine'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'proof/:id?',
            component: () => import('@/views/Purchase/Payment/Proof.vue'),
            name: 'PaymentProof',
            meta: {
              title: t('router.purchase.payment.proof'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Purchase/Payment/Add.vue'),
            name: 'PaymentAdd',
            meta: {
              title: t('router.purchase.payment.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      }
      // {
      //   path: 'audit-management',
      //   component: () => import('@/views/Purchase/Purchase/Page.vue'),
      //   name: 'AuditManagement',
      //   meta: {
      //     title: t('router.purchase.audit.page')
      //   }
      // }
    ]
  },
  {
    path: '/product',
    component: Layout,
    redirect: '/product/product-management',
    name: 'Product',
    meta: {
      title: t('router.product.product.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'product-management',
        component: () => import('@/views/Product/Product/Page.vue'),
        name: 'ProductManagement',
        meta: {
          title: t('router.product.product.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Product/Product/Detail.vue'),
            name: 'ProductDetail',
            meta: {
              title: t('router.product.product.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Product/Product/Add.vue'),
            name: 'ProductAdd',
            meta: {
              title: t('router.product.product.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Product/Product/Edit.vue'),
            name: 'ProductEdit',
            meta: {
              title: t('router.product.product.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'category-management',
        component: () => import('@/views/Product/Category/Page.vue'),
        name: 'CategoryManagement',
        meta: {
          title: t('router.product.category.page')
        },
        children: [
          {
            path: 'add',
            component: () => import('@/views/Product/Category/Add.vue'),
            name: 'CategoryAdd',
            meta: {
              title: t('router.category.category.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Product/Category/Edit.vue'),
            name: 'CategoryEdit',
            meta: {
              title: t('router.product.category.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Product/Category/Detail.vue'),
            name: 'CategoryDetail',
            meta: {
              title: t('router.product.category.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'brand-management',
        component: () => import('@/views/Product/Brand/Page.vue'),
        name: 'BrandManagement',
        meta: {
          title: t('router.product.brand.page')
        },
        children: [
          {
            path: 'add',
            component: () => import('@/views/Product/Brand/Add.vue'),
            name: 'BrandAdd',
            meta: {
              title: t('router.product.brand.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Product/Brand/Edit.vue'),
            name: 'BrandEdit',
            meta: {
              title: t('router.product.brand.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Product/Brand/Detail.vue'),
            name: 'BrandDetail',
            meta: {
              title: t('router.product.brand.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'attachment-management',
        component: () => import('@/views/Product/Attachment/Page.vue'),
        name: 'AttachmentManagement',
        meta: {
          title: t('router.product.attachment.page')
        },
        children: [
          {
            path: 'add',
            component: () => import('@/views/Product/Attachment/Add.vue'),
            name: 'AttachmentAdd',
            meta: {
              title: t('router.product.attachment.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Product/Attachment/Edit.vue'),
            name: 'AttachmentEdit',
            meta: {
              title: t('router.product.attachment.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Product/Attachment/Detail.vue'),
            name: 'AttachmentDetail',
            meta: {
              title: t('router.product.attachment.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'currency-management',
        component: () => import('@/views/Product/Currency/Page.vue'),
        name: 'CurrencyManagement',
        meta: {
          title: t('router.product.currency.page')
        },
        children: [
          {
            path: 'add',
            component: () => import('@/views/Product/Currency/Add.vue'),
            name: 'CurrencyAdd',
            meta: {
              title: t('router.product.currency.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Product/Currency/Edit.vue'),
            name: 'CurrencyEdit',
            meta: {
              title: t('router.product.currency.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Product/Currency/Detail.vue'),
            name: 'CurrencyDetail',
            meta: {
              title: t('router.product.currency.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      }
    ]
  },
  {
    path: '/warehouse',
    component: Layout,
    redirect: '/warehouse/warehouse-management',
    name: 'Warehouse',
    meta: {
      title: t('router.warehouse.warehouse.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'warehouse-management',
        component: () => import('@/views/Warehouse/Warehouse/Page.vue'),
        name: 'WarehouseManagement',
        meta: {
          title: t('router.warehouse.warehouse.page')
        },
        children: [
          {
            path: 'add',
            component: () => import('@/views/Warehouse/Warehouse/Add.vue'),
            name: 'WarehouseAdd',
            meta: {
              title: t('router.warehouse.warehouse.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Warehouse/Warehouse/Edit.vue'),
            name: 'WarehouseEdit',
            meta: {
              title: t('router.warehouse.warehouse.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Warehouse/Warehouse/Detail.vue'),
            name: 'WarehouseDetail',
            meta: {
              title: t('router.warehouse.warehouse.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'inventory-management',
        component: () => import('@/views/Warehouse/Inventory/Page.vue'),
        name: 'InventoryManagement',
        meta: {
          title: t('router.warehouse.inventory.page')
        },
        children: [
          {
            path: 'edit/:id?',
            component: () => import('@/views/Warehouse/Inventory/Edit.vue'),
            name: 'InventoryEdit',
            meta: {
              title: '库存-编辑',
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Warehouse/Inventory/Detail.vue'),
            name: 'InventoryDetail',
            meta: {
              title: t('router.warehouse.inventory.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'conversion',
            component: () => import('@/views/Warehouse/Inventory/conversion.vue'),
            name: 'Conversion',
            meta: {
              title: t('router.warehouse.inventory.conversion'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'checking',
            component: () => import('@/views/Warehouse/Inventory/checking.vue'),
            name: 'Checking',
            meta: {
              title: '校对审核',
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'transaction-currency',
        redirect: '/warehouse/transaction-currency/page',
        name: 'TransactionCurrency',
        meta: {
          title: t('router.warehouse.transaction_currency.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Warehouse/TransactionCurrency/Page.vue'),
            name: 'TransactionCurrencyPage',
            meta: {
              title: t('router.warehouse.transaction_currency.page'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Warehouse/TransactionCurrency/Add.vue'),
            name: 'TransactionCurrencyAdd',
            meta: {
              title: t('router.warehouse.transaction_currency.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit',
            component: () => import('@/views/Warehouse/TransactionCurrency/Edit.vue'),
            name: 'TransactionCurrencyEdit',
            meta: {
              title: t('router.warehouse.transaction_currency.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'detail',
            component: () => import('@/views/Warehouse/TransactionCurrency/Detail.vue'),
            name: 'TransactionCurrencyDetail',
            meta: {
              title: t('router.warehouse.transaction_currency.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/order-management',
    name: 'Order',
    meta: {
      title: t('router.order.order.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'order-management',
        component: () => import('@/views/Order/Order/Page.vue'),
        name: 'OrderManagement',
        meta: {
          title: t('router.order.order.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Order/Order/Detail.vue'),
            name: 'OrderDetail',
            meta: {
              title: t('router.order.order.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Order/Order/Add.vue'),
            name: 'OrderAdd',
            meta: {
              title: t('router.order.order.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Order/Order/Edit.vue'),
            name: 'OrderEdit',
            meta: {
              title: t('router.order.order.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      },
      {
        path: 'wholesal-order-management',
        component: () => import('@/views/Order/WholesalOrder/Page.vue'),
        name: 'WholesalOrderManagement',
        meta: {
          title: t('router.order.wholesal.page')
        },
        children: [
          {
            path: 'detail/:id?',
            component: () => import('@/views/Order/WholesalOrder/Detail.vue'),
            name: 'WholesalOrderDetail',
            meta: {
              title: t('router.order.wholesal.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Order/WholesalOrder/Add.vue'),
            name: 'WholesalOrderAdd',
            meta: {
              title: t('router.order.wholesal.add'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          },
          {
            path: 'edit/:id?',
            component: () => import('@/views/Order/WholesalOrder/Edit.vue'),
            name: 'OrderEdit',
            meta: {
              title: t('router.order.wholesal.edit'),
              noTagsView: true,
              hidden: true,
              canTo: true
            }
          }
        ]
      }
    ]
  },
  {
    path: '/logistics',
    component: Layout,
    redirect: '/logistics/rules/page',
    name: 'Logistics',
    meta: {
      title: t('router.logistics.rules.menu'),
      keepAlive: true,
      alwaysShow: true
    },
    children: [
      {
        path: 'rules',
        redirect: '/logistics/rules/page',
        name: 'Rules',
        meta: {
          title: t('router.logistics.rules.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Logistics/Rules/Page.vue'),
            name: 'RulesPage',
            meta: {
              title: t('router.logistics.rules.page')
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Logistics/Rules/Add.vue'),
            name: 'RulesAdd',
            meta: {
              title: t('router.logistics.rules.add'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/rules/page'
            }
          },
          {
            path: 'edit',
            component: () => import('@/views/Logistics/Rules/Edit.vue'),
            name: 'RulesEdit',
            meta: {
              title: t('router.logistics.rules.edit'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/rules/page'
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Logistics/Rules/Detail.vue'),
            name: 'RulesDetail',
            meta: {
              title: t('router.logistics.rules.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/rules/page'
            }
          }
        ]
      },
      {
        path: 'company',
        redirect: '/logistics/company/page',
        name: 'Company',
        meta: {
          title: t('router.logistics.company.menu')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Logistics/Company/Page.vue'),
            name: 'CompanyPage',
            meta: {
              title: t('router.logistics.company.page')
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Logistics/Company/Detail.vue'),
            name: 'CompanyDetail',
            meta: {
              title: t('router.logistics.company.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/company/page'
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Logistics/Company/Add.vue'),
            name: 'CompanyAdd',
            meta: {
              title: t('router.logistics.company.add'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/company/page'
            }
          },
          {
            path: 'edit',
            component: () => import('@/views/Logistics/Company/Edit.vue'),
            name: 'CompanyEdit',
            meta: {
              title: t('router.logistics.company.edit'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/logistics/company/page'
            }
          }
        ]
      },
      {
        path: 'classification',
        redirect: '/logistics/classification/page',
        name: 'Classification',
        meta: {
          title: t('router.logistics.classification.menu')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Logistics/Classification/Page.vue'),
            name: 'CompanyPage',
            meta: {
              title: t('router.logistics.classification.page')
            }
          }
        ]
      }
    ]
  },
  {
    path: '/customer-module',
    component: Layout,
    redirect: '/customer-module/customer/page',
    name: 'CustomerModule',
    meta: {
      title: t('router.customer.customer.menu'),
      keepAlive: true,
      alwaysShow: true
    },
    children: [
      {
        path: 'customer',
        redirect: '/customer-module/customer/page',
        name: 'Customer',
        meta: {
          title: t('router.customer.customer.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Customer/Customer/Page.vue'),
            name: 'CustomerPage',
            meta: {
              title: t('router.customer.customer.page')
            }
          },
          {
            path: 'public-page',
            component: () => import('@/views/Customer/Customer/PublicPage.vue'),
            name: 'CustomerPublicPage',
            meta: {
              title: t('router.customer.customer.publicPage')
            }
          },
          {
            path: 'detail/:id?',
            component: () => import('@/views/Customer/Customer/Detail.vue'),
            name: 'CustomerDetail',
            meta: {
              title: t('router.customer.customer.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer/page'
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Customer/Customer/Add.vue'),
            name: 'CustomerAdd',
            meta: {
              title: t('router.customer.customer.add'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer/page'
            }
          },
          {
            path: 'edit',
            component: () => import('@/views/Customer/Customer/Edit.vue'),
            name: 'CustomerEdit',
            meta: {
              title: t('router.customer.customer.edit'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer/page'
            }
          }
        ]
      },
      {
        path: 'customer-contact',
        redirect: '/customer-module/customer-contact/page',
        name: 'CustomerContact',
        meta: {
          title: t('router.customer.customerContact.menu')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Customer/CustomerContact/Page.vue'),
            name: 'CustomerContactPage',
            meta: {
              title: t('router.customer.customerContact.page')
            }
          },
          {
            path: 'detail',
            component: () => import('@/views/Customer/CustomerContact/Detail.vue'),
            name: 'CustomerContactDetail',
            meta: {
              title: t('router.customer.customerContact.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer-contact/page'
            }
          },
          {
            path: 'add',
            component: () => import('@/views/Customer/CustomerContact/Add.vue'),
            name: 'CustomerContactAdd',
            meta: {
              title: t('router.customer.customerContact.add'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer-contact/page'
            }
          },
          {
            path: 'edit',
            component: () => import('@/views/Customer/CustomerContact/Edit.vue'),
            name: 'CustomerContactEdit',
            meta: {
              title: t('router.customer.customerContact.edit'),
              noTagsView: true,
              noCache: true,
              hidden: true,
              canTo: true,
              activeMenu: '/customer-module/customer-contact/page'
            }
          }
        ]
      }
    ]
  },
  {
    path: '/authorization',
    component: Layout,
    redirect: '/authorization/user',
    name: 'Authorization',
    meta: {
      title: t('router.authorization.menu'),
      // icon: 'vi-eos-icons:role-binding',
      alwaysShow: true
    },
    children: [
      {
        path: 'department',
        redirect: '/authorization/department/page',
        name: 'Department',
        meta: {
          title: t('router.authorization.department.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Authorization/Department/Page.vue'),
            name: 'DepartmentPage',
            meta: {
              title: t('router.authorization.department.page')
            }
          }
        ]
      },
      {
        path: 'operator',
        redirect: '/authorization/operator/page',
        name: 'Operator',
        meta: {
          title: t('router.authorization.operator.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Authorization/Operator/Page.vue'),
            name: 'OperatorPage',
            meta: {
              title: t('router.authorization.operator.page')
            }
          }
        ]
      },
      {
        path: 'menu',
        component: () => import('@/views/Authorization/Menu/Menu.vue'),
        name: 'Menu',
        meta: {
          title: t('router.menuManagement')
        }
      },
      {
        path: 'role',
        redirect: '/authorization/role/page',
        name: 'Role',
        meta: {
          title: t('router.authorization.role.page')
        },
        children: [
          {
            path: 'page',
            component: () => import('@/views/Authorization/Role/Page.vue'),
            name: 'RolePage',
            meta: {
              title: t('router.authorization.role.page')
            }
          }
        ]
      }
    ]
  },
  {
    path: '/market',
    component: Layout,
    redirect: '/market/industryNews',
    name: 'Market',
    meta: {
      title: t('router.market.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'industryNews',
        component: () => import('@/views/Market/IndustryNews/Page.vue'),
        name: 'IndustryNews',
        meta: {
          title: t('router.market.industryNews.page')
        },
        children: [
          {
            path: 'detail',
            component: () => import('@/views/Market/IndustryNews/Detail.vue'),
            name: 'IndustryNewsDetail',
            meta: {
              title: t('router.market.industryNews.detail'),
              noTagsView: true,
              hidden: true,
              canTo: true,
              activeMenu: '/market/industryNews'
            }
          }
        ]
      }
      // {
      //   path: 'marketChannel',
      //   component: () => import('@/views/Market/MarketChannel/Page.vue'),
      //   name: 'MarketChannel',
      //   meta: {
      //     title: t('router.market.marketChannel.page')
      //   }
      // },
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: '/system/parameterConfig',
    name: 'System',
    meta: {
      title: t('router.system.menu'),
      alwaysShow: true
    },
    children: [
      {
        path: 'parameterConfig',
        component: () => import('@/views/System/ParameterConfig/Page.vue'),
        name: 'ParameterConfig',
        meta: {
          title: t('router.system.parameterConfig.page')
        }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  strict: true,
  routes: constantRouterMap as RouteRecordRaw[],
  scrollBehavior: () => ({ left: 0, top: 0 })
})

export const resetRouter = (): void => {
  const resetWhiteNameList = ['Redirect', 'Login', 'NoFind', 'Root']
  router.getRoutes().forEach((route) => {
    const { name } = route
    if (name && !resetWhiteNameList.includes(name as string)) {
      router.hasRoute(name) && router.removeRoute(name)
    }
  })
}

export const setupRouter = (app: App<Element>) => {
  app.use(router)
}

export default router
